package com.yulongtian.offers.day202212;

/**
 * https://leetcode.cn/problems/is-subsequence/
 * 可
 *
 * @author yulongTian
 * @create 2022-12-14 11:16
 */
public class Test04 {
    public static void main(String[] args) {

    }

    public static boolean isSubsequence(String s, String t) {
        int lenS = s.length();
        int lenT = t.length();

        if (lenS > lenT) {
            return false;
        }
        if (lenS == 0) {
            return true;
        }

        int pointS = 0;
        int pointT = 0;

        while (pointS < lenS && pointT < lenT) {

            if (s.charAt(pointS) == t.charAt(pointT)) {
                pointS++;
                pointT++;
            } else {
                pointT++;
            }
        }

        if (pointS == lenS) {
            return true;
        }

        return false;
    }


}
